import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;

import javax.swing.JComponent;


public class HeapComponent extends JComponent
{
	Heap heap;
	Comparable[] arr;
	final int WIDTH = 600;
	int height;
	
	HeapComponent(Heap heap)
	{
		super();
		this.heap = heap;
		this.arr = heap.getArr();
		height = (int) (700 / Math.log(arr.length));
	}
	public void paintComponent(Graphics g)
	{
		
		Graphics2D g2 = (Graphics2D) g;
		
		g2.setColor(Color.black);
		int currentX = WIDTH / 2;
		int currentY = 20;
		//g2.drawString(arr[0].toString(), currentX, currentY);
//		int level = 0;
		for(int level = 0; level < Math.floor(Math.log(arr.length)/Math.log(2)); level++)
		{
			System.out.println("level = " + level);
			int xInc = WIDTH / (int) Math.pow(2, level);
			for(int i = 0; i < Math.pow(2, level); i++)
			{
				g2.drawString(arr[(int)Math.pow(2, level) -1 + i].toString(), xInc * i + 50, level * 20 + 50);
			}
			
		}
		
		
	}
}
